package com.ruoyi.project.im.friends.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.im.friends.mapper.FriendsMapper;
import com.ruoyi.project.im.friends.domain.Friends;
import com.ruoyi.project.im.friends.service.IFriendsService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 用户好友Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-11
 */
@Service
public class FriendsServiceImpl implements IFriendsService
{
    @Autowired
    private FriendsMapper friendsMapper;

    /**
     * 查询用户好友
     *
     * @param ownerUserId 用户好友主键
     * @return 用户好友
     */
    @Override
    public Friends selectFriendsByOwnerUserId(String ownerUserId)
    {
        return friendsMapper.selectFriendsByOwnerUserId(ownerUserId);
    }

    @Override
    public List<Friends> selectAllFriendsByOwnerUserId(String ownerUserId)
    {
        return friendsMapper.selectAllFriendsByOwnerUserId(ownerUserId);
    }

    /**
     * 查询用户好友列表
     *
     * @param friends 用户好友
     * @return 用户好友
     */
    @Override
    public List<Friends> selectFriendsList(Friends friends)
    {
        return friendsMapper.selectFriendsList(friends);
    }

    public Friends selectOneFriend(Friends friends){
        return friendsMapper.selectOneFriend(friends);
    }

    /**
     * 新增用户好友
     *
     * @param friends 用户好友
     * @return 结果
     */
    @Override
    public int insertFriends(Friends friends)
    {
        friends.setCreateTime(DateUtils.getNowDate());
        return friendsMapper.insertFriends(friends);
    }

    /**
     * 修改用户好友
     *
     * @param friends 用户好友
     * @return 结果
     */
    @Override
    public int updateFriends(Friends friends)
    {
        return friendsMapper.updateFriends(friends);
    }

    /**
     * 批量删除用户好友
     *
     * @param ownerUserIds 需要删除的用户好友主键
     * @return 结果
     */
    @Override
    public int deleteFriendsByOwnerUserIds(String ownerUserIds)
    {
        return friendsMapper.deleteFriendsByOwnerUserIds(Convert.toStrArray(ownerUserIds));
    }

    /**
     * 删除用户好友信息
     *
     * @param ownerUserId 用户好友主键
     * @return 结果
     */
    @Override
    public int deleteFriendsByOwnerUserId(String ownerUserId)
    {
        return friendsMapper.deleteFriendsByOwnerUserId(ownerUserId);
    }
}
